package View;

import Request.StudentRequest;
import Reservice.TableDTO;
import Service.Student;
import Service.impl.Studen;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import java.awt.*;
import java.util.Vector;

public class Right extends Box {
    public Right(){
        super(BoxLayout.Y_AXIS);
//        Vector<String> clumns=new Vector<>();
//        clumns.addElement("编号");
//        clumns.addElement("姓名");
//        clumns.addElement("性别");
//        clumns.addElement("联系方式");
        Student student=new Studen();
        StudentRequest request=new StudentRequest();
        request.setPageNow(1);
        request.setPageSize(100);
//        request.setSearchKey(getToolTipText().trim());
        TableDTO tableDTO = student.retrieveStudents(request);
        Vector<Vector<Object>>data=tableDTO.getData();


//        DefaultTableModel tableModel=new DefaultTableModel();
//        tableModel.setDataVector(data,clumns);
        jiaoshi j = jiaoshi.zuzhang(data);
        JTable jTable=new JTable(j);

        JTableHeader tableHeader=jTable.getTableHeader();
        tableHeader.setFont(new Font(null, Font.BOLD,18));
        tableHeader.setForeground(Color.BLACK);
//
//        jTable=new JTable(tableModel){
//            @Override
//            public boolean isCellEditable(int row, int column) {
//                return false;
//            }
//        };

        JScrollPane scro=new JScrollPane(jTable);
        this.add(scro);
    }
}
class jiaoshi extends DefaultTableModel{
     static Vector<String> clumns=new Vector<>();
     static {
//         clumns.addElement("id");
         clumns.addElement("学号");
         clumns.addElement("密码");
         clumns.addElement("姓名");
         clumns.addElement("面向对象程序设计");
         clumns.addElement("python程序设计");
         clumns.addElement("c语言");
     }
     public jiaoshi(){
         super(null,clumns);
     }
     private static jiaoshi jiaoshi=new jiaoshi();
     public static jiaoshi zuzhang(Vector<Vector<Object>> data){
        jiaoshi.setDataVector(data,clumns);
         return jiaoshi;
     }
    public  void updatem(Vector<Vector<Object>> data) {
        jiaoshi.setDataVector(data, clumns);
    }

    @Override
    public boolean isCellEditable(int row, int column) {
        return false;
    }
}